﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Chess
{
    public class Pawn : InterfacePiece
    {
        Piece piece = null;

        public Pawn(Piece Pawn)
        {
            piece = Pawn;
        }
       
        public int ImageIndex
        {
            get { return (this.piece.Player.isColor == Player.Color.BLACK ? 1 : 0); }
        }              

        public void SetPosition(Moves moves)
        {
            Square square;
            
            if((square = Board.GetSquare(piece.Square.Ordinal + piece.Player.PawnForwardOffset)) != null && square.Piece == null)
                moves.Add(this.piece, this.piece.Square, square, square.Piece);                
          
            if ((square = Board.GetSquare(piece.Square.Ordinal + piece.Player.PawnAttackRightOffset)) != null)
                if (square.Piece != null && square.Piece.Player.isColor != piece.Player.isColor)
                    moves.Add(this.piece, this.piece.Square, square, square.Piece);
          
            if ((square = Board.GetSquare(piece.Square.Ordinal + piece.Player.PawnAttackLeftOffset)) != null)
                if (square.Piece != null && square.Piece.Player.isColor != piece.Player.isColor)
                    moves.Add(this.piece, this.piece.Square, square, square.Piece);            

        }
    }
}
